/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.DataAccess
*        文件名:             BaseProjectDao.cs
*        创建系统时间:       2012/11/2 19:07:00
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.DataAccess
{
    using System.Data;
    using ECP.DataAccess.Utilities;
    using ECP.Model;
    using ECP.Utilities;

    public class BaseProjectDao : BaseDao
    {
        public BaseProjectDao()
        {
            base.CurrentTableName = BaseProjectTable.TableName;
        }

        public BaseProjectDao(IDbHelper dbHelper)
            : this()
        {
            base.DbHelper = dbHelper;
        }

        public BaseProjectDao(BaseUserInfo userInfo)
            : this()
        {
            base.UserInfo = userInfo;
        }

        public BaseProjectDao(IDbHelper dbHelper, BaseUserInfo userInfo)
            : this(dbHelper)
        {
            base.UserInfo = userInfo;
        }

        public string FieldToList(DataTable dataTable)
        {
            return "";
        }

        public DataTable GetList()
        {
            string sqlQuery = " SELECT  ID, Code, FullName, CategoryID, Description, Enabled, OrganizeID, ManagerID, CategoryID,  (SELECT FullName FROM " + BaseOrganizeTable.TableName + " WHERE (ID = T_Project.OrganizeID)) AS OrganizeFullName , (SELECT FullName FROM " + BaseStaffTable.TableName + " WHERE (ID = T_Project.ManagerID)) AS ManagerFullName , (SELECT FullName FROM T_ItemDetails WHERE (ID = T_Project.CategoryID)) AS CategoryFullName  FROM " + BaseProjectTable.TableName;
            DataTable dataTable = new DataTable(BaseProjectTable.TableName);
            base.DbHelper.Fill(dataTable, sqlQuery);
            return dataTable;
        }

        public string IDToCode(string id)
        {
            return this.GetProperty(id, BaseProjectTable.FieldCode);
        }
    }
}